from sympy import Function, symbols, idiff, simplify

x = symbols('x')
y = Function('y')(x)
equation = x**2 + y**2 - x*y - 1

# 使用 idiff 函数直接计算隐函数的高阶导数
y_prime = idiff(equation, y, x)  # 一阶导数
y_double_prime = idiff(equation, y, x, n=2)  # 二阶导数

print("隐函数的高阶导数:")
print(f"方程: {equation} = 0")
print(f"一阶导数: dy/dx = {y_prime}")
print(f"二阶导数: d²y/dx² = {y_double_prime}")